package com.example.flyweight;

import com.example.flyweight.content.Tree;
import com.example.flyweight.content.TreeType;

/**
 * 享元模式，通过共享内部状态，减少对象的创建
 */
public class Test {
    public static void main(String[] args) {
        TreeType treeType1 = TreeFactory.getTreeType(1, "橡树", "绿色", 10);
        TreeType treeType = TreeFactory.getTreeType(1, "橡树", "绿色", 10);
        TreeType treeType2 = TreeFactory.getTreeType(2, "橡树", "绿色", 10);
//        TreeType treeType2 = TreeFactory.getTreeType("松树", "黄色", 20);

        Tree tree1 = new Tree(2, 3, treeType1);
        Tree tree2 = new Tree(3, 4, treeType1);

        tree1.draw();
        tree2.draw();
    }
}
